﻿using QuadRemote.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;

namespace QuadRemote.Tabs
{
    class SessionTab : TabPage
    {
        BluetoothStatus btStatus;
        LogPanel logPanel;

        public SessionTab() : base("Session")
        {
            logPanel = new LogPanel();
            logPanel.Location = new Point(5, 5);
            Controls.Add(logPanel);

            //btStatus = new BluetoothStatus(500, 300);
            //btStatus.Location = new Point(5, 5);
            //Controls.Add(btStatus);

            /*            Button save = new Button();
                        save.Click += save_Click;
                        save.Text = "Save";
                        save.Location = new System.Drawing.Point(5, 500);
                        Controls.Add(save);

                        Button load = new Button();
                        load.Click += load_Click;
                        load.Text = "Load";
                        load.Location = new System.Drawing.Point(200, 500);
                        Controls.Add(load);
            */
            Resize += SessionTab_Resize;

        }

        void load_Click(object sender, EventArgs e)
        {
            OpenFileDialog file = new OpenFileDialog();
            file.Filter = "Quad (*.quad)|*.quad";
            file.ShowDialog();
            if (file.FileName == "") return;
            new FlightSession(file.FileName);
        }

        void save_Click(object sender, EventArgs e)
        {
            SaveFileDialog file = new SaveFileDialog();
            file.Filter = "Quad|*.quad";
            file.ShowDialog();
            if (file.FileName == "") return;
            Console.WriteLine(file.FileName);
            FlightSession.current().save(file.FileName);
        }

        void SessionTab_Resize(object sender, EventArgs e)
        {
            //btStatus.Size = new System.Drawing.Size(Width - logPanel.Width - 20, 300);
            //btStatus.Location = new System.Drawing.Point(logPanel.Width + logPanel.Left + 10, 5);
        }
    }
}
